package controlador;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import java.util.Vector;

import modelo.dto.Nivel;
import modelo.dao.NivelDao;
import vista.vNivel;

public class cNivel implements ActionListener{
private vNivel vnivel;
	
	public cNivel() {
		super();
		vnivel = new vNivel();
		vnivel.setLocationRelativeTo(null);
		vnivel.setVisible(true);	
		vnivel.addListener(this);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		String accion=e.getActionCommand();
		if(accion=="Basico"){
			new cMastermind(contrasena(4));
		    vnivel.dispose();
		}
		else if(accion=="Intermedio")
		{	
			
			new cMastermind(contrasena(5));
			vnivel.dispose();
		}
		else if(accion=="Dificil")
			{
			new cMastermind(contrasena(6));
			vnivel.dispose();
			}
		else if(accion==("Atras"))
				{
			     new cMenuPrincipal();
			     vnivel.dispose();
				}else if(accion=="Puntuacion"){
			new cListaPuntuacion();
			vnivel.dispose();
		}
	}
    public Nivel contrasena(int dificultad)
    {
    	NivelDao niveldao=new NivelDao();
    	Vector<Nivel> nivel=new Vector<Nivel>();
    	nivel=niveldao.ExtraerNivel(dificultad);
    	Random random = new Random();
    	//System.out.print(nivel.size());
    	int i = random.nextInt(nivel.size());
    	return nivel.get(i);
    }

}
